
<section>
	<div class="page_title">
		<h2 class="fl">管理员列表</h2>
        <a class="fr top_rt_btn iconfont iconfont-tianjiayonghu" href="{:U('admin/User/addUser')}" style="margin-right: 10px">添加管理员</a>
        <!--<a class="fr top_rt_btn iconfont iconfont-tianjiayonghu" href="{:U('admin/User/export')}">导出管理员</a>-->
	</div>
	{include file="public/public_search" /}
	<table class="table">
		<tbody><tr>
			<th>用户名</th>
			<th><i class="icon-time bigger-110 hidden-480"></i>上次登录时间</th>
			<th>
				上次登录IP
			</th>
			<th>注册时间</th>
			<th>状态</th>
			<th>用户所属组别</th>
			<th>操作</th>
		</tr>
		{volist name='user' id='v'}
		{if condition="!in_array($v[id],C('ADMINISTRATOR')) && $v['id'] != decrypt_id(session('aid'))"}
		<tr>
			<td>{$v.username}</td>
			<td>{if condition=" $v['login_time']  neq 0 "}{$v.login_time|date='Y-m-d H:i', ###}{/if}</td>
			<td>{$v.login_ip}</td>
			<td>{$v.rsgtime|date='Y-m-d H:i', ###}</td>
			<td>
				<input type="checkbox" id="checkbox_live{$i}" data-id="{:encrypt_id($v.id)}" data-lock="{$v.lock}" class="chk_4 conf_status userlock" {eq name='v.lock' value='1'}checked{/eq} />
				<label for="checkbox_live{$i}">
					<input type="hidden" value="{$vo.lock}" />
				</label>
				<!--<a class="inner_btn userlock" data-id="{:encrypt_id($v.id)}" data-lock="{$v.lock}">{eq name="v.lock" value="1"}启用中{else /}禁用{/eq}</a>-->
			</td>
			<td>
				{$v.groupname}
			</td>
			<td>
				<div class="action-buttons">
					<a class="green loadContent"  href="{:U('admin/User/updateuser',array('id'=>encrypt_id($v.id)))}">
						<i class="iconfont iconfont-bianji inner_btn" style="color: #949496">&nbsp;编辑</i>
					</a> |
					<a class="delUser loadContent" href="javascript:void(0)" data-id="{:encrypt_id($v.id)}">
						<i class="iconfont iconfont-shanchu inner_btn" style="color: #949496">&nbsp;删除</i>
					</a>
				</div>
			</td>
		</tr>
		{/if}
		{/volist}
		</tbody>
	</table>
	<aside class="paging">
		{$page.html}
	</aside>
</section>
<script type="text/javascript">
	$('.userlock').click(function () {
		var id = $(this).data('id');
		var lockid = $(this).data('lock') == 1 ? 1 : 0;
		if(lockid == 1)
		{
			var lock = 0;
		}else
		{
			var lock = 1;
		}
		send_data = {
			url:U('admin/User/UserLock'),
			type:'POST',
			data:{
				id:id,
				lock:lock
			},
			dataType:'json',

		};
		send_ajax(send_data,function(res){
			if(res.status == 1){
				msg_success('操作成功.','',2000);
				setTimeout(function(){
					admin.getContentByUrl(res.data.jumpurl);
				},2000);
			}else{
				msg_error(res.message);
			}
		})
	})
</script>
<script type="text/javascript">
	$(".delUser").click(function(){
		var id = $(this).data('id');
		msg({
			yes:'删除',
			no:'取消',
			txt:'确认删除?',
		},'question').then(function() {
			var send_data = {
				url:U('admin/User/delUser'),
				type:'POST',
				data:{id:id},
				dataType:'json',
			};
			send_ajax(send_data,function(response){
				if(response === false){
					DEBUG && admin.log(ajax_error);
					return false;
				}
				if(response.status == 1){
					msg_success(response.data.info,'',1000);
					setTimeout(function(){
						admin.getContentByUrl(response.data.jumpurl);
					},1000);
				}else{
					msg_error(response.message);
				}
				admin.log(response);
			});


		}, function(miss) {
			//dismiss can be 'cancel', 'overlay', 'close', 'timer'
			//if (miss === 'cancel') {
			//msg('你取消了')
			//}
		});
	});
</script>

<script type="text/javascript">
	jQuery(function($) {
		$('table th input:checkbox').on('click' , function(){
			var that = this;
			$(this).closest('table').find('tr > td:first-child input:checkbox')
			.each(function(){
				this.checked = that.checked;
				$(this).closest('tr').toggleClass('selected');
			});
		});
	})
</script>